const http = require('http')
const url = require('url')
const qs = require('querystring')

const server = http.createServer((req, res) => {
  console.log(req)
  const {
    pathname
  } = url.parse(req.url)
  if (pathname === '/login') {
    if (req.method === 'POST') {
      // req.setEncoding('utf-8')
      req.on('data', (data) => {
        console.log(data)
        // console.log(JSON.parse(data.toString()));
      })
      res.end('登陆成功')
    } else {
      res.end('登录失败')
    }
  }

})

server.listen(8000, () => {
  console.log('服务器启动成功')
})